//package com.geostar.constructionland.analyse.service.adjust;
//
//import com.geostar.constructionland.analyse.agri.AdjustAgri;
//import com.geostar.constructionland.common.entity.response.LandInfo;
//
//import java.math.BigDecimal;
//import java.util.Comparator;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * @Author:Yell
// * @Since:2020-8-4 11:37
// */
//public class TzhGdFxAdjustAgr extends PAdjust{
//
//    public TzhGdFxAdjustAgr(double adjustThreshold, double adjustUnit, List<LandInfo> landInfos, double adjustTotal) {
//        super(adjustThreshold, adjustUnit, landInfos, adjustTotal);
//    }
//    @Override
//    public List<LandInfo> adjust() throws Exception {
//        landInfos.forEach(landInfo -> {
//            double zymj = new BigDecimal(landInfo.getZymj_ys()).setScale(0,BigDecimal.ROUND_HALF_UP).doubleValue();
//            landInfo.setZymj(zymj);
//            landInfo.setZymj_adjusted(zymj);
//            BigDecimal zymj_ys_bd_round_down =  new BigDecimal(landInfo.getZymj_ys());
//            zymj_ys_bd_round_down = zymj_ys_bd_round_down.setScale(1,BigDecimal.ROUND_DOWN);
//            BigDecimal zymj_ys_bd_scale =  new BigDecimal(landInfo.getZymj_ys());
//            zymj_ys_bd_scale = zymj_ys_bd_scale.setScale(0,BigDecimal.ROUND_HALF_UP);
//            double disBtwZymjDis = (zymj_ys_bd_round_down.subtract(zymj_ys_bd_scale)).doubleValue();
//            landInfo.setDisBtwZymjDis(disBtwZymjDis);
//        });
//        /**不需要平差则返回数据**/
//        if(adjustTotal == 0 ){
//            return landInfos;
//        }
//        BigDecimal sub_mj = new BigDecimal(adjustTotal);
//        if(sub_mj.compareTo(new BigDecimal(0)) > 0){
//            /**按照原始占压面积从大到小**/
//            landInfos = landInfos.stream().sorted(Comparator.comparing(LandInfo::getPcxh)).sorted(Comparator.comparing(LandInfo::getDkmj_ys,Comparator.reverseOrder())
//                    .thenComparing(LandInfo::getDisBtwZymjDis,Comparator.reverseOrder())).collect(Collectors.toList());
//        }else{
//            /**按照原始地块面积从小到大**/
//            landInfos = landInfos.stream().sorted(Comparator.comparing(LandInfo::getPcxh)).sorted(Comparator.comparing(LandInfo::getDkmj_ys,Comparator.reverseOrder())
//                    .thenComparing(LandInfo::getDisBtwZymjDis)).collect(Collectors.toList());
//            /**设置平差单位**/
//            adjustUnit = adjustUnit * -1;
//        }
//        /**平差总值**/
//        double adjustTotal = Math.abs(sub_mj.intValue());
//        /**执行平差**/
//        landInfos = AdjustAgri.adjust(landInfos, adjustTotal, adjustUnit);
//        return landInfos;
//    }
//}
